/*
  Copyright (c) 2020 classmate-sun
  [Software Name] is licensed under Mulan PSL v2.
  You can use this software according to the terms and conditions of the Mulan PSL v2.
  You may obtain a copy of Mulan PSL v2 at:
          http://license.coscl.org.cn/MulanPSL2
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  See the Mulan PSL v2 for more details.
*/

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import config from './config'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import nprogress from 'nprogress'
import 'nprogress/nprogress.css'
import axios from 'axios'
import mavonEditor from "mavon-editor"
import "mavon-editor/dist/css/index.css"
import APlayer from '@moefe/vue-aplayer';


Vue.use(mavonEditor)
Vue.use(APlayer,{
    defaultCover: 'https://github.com/u3u.png',
    productionTip: true,
})
Vue.prototype.$config=config;

// 添加请求拦截器，在请求头中加token
axios.interceptors.request.use(
    config => {
        if (localStorage.getItem('Authorization')) {
            config.headers.Authorization = localStorage.getItem('Authorization');
        }
        return config;
    },
    error => {
        return Promise.reject(error);
    }
  );
// axios.defaults.baseURL='/api';
axios.defaults.timeout=30000;
Vue.prototype.$ajax = axios;
router.beforeEach((to,from,next)=>{
  nprogress.start();
  next();
})

router.afterEach((to,from)=>{
  window.scrollTo(0,0);
  nprogress.done();
})

Vue.use(ElementUI)

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
